home *** CD-ROM | disk | FTP | other *** search
/ Champak 52 / Volume 52 - JOGO DISK .iso / Games / shopdrop.swf / scripts / __Packages / MallWorld.as < prev    next >
Text File  |  2007-09-27  |  4KB  |  161 lines

  1. class MallWorld implements smashing.World
  2. {
  3.    var flScore = 0;
  4.    var score = 0;
  5.    var level = 1;
  6.    var bCollapse = false;
  7.    var nDist = 60;
  8.    var cDist = 0;
  9.    var scoreValue = 1;
  10.    var levelScore = 0;
  11.    var highestStack = 0;
  12.    var maxStackBonus = 200;
  13.    var maxStackScore = 0;
  14.    var bonusScore = 300;
  15.    function MallWorld(loc)
  16.    {
  17.       if(_global.bTries == true)
  18.       {
  19.          this.nLives = 5;
  20.       }
  21.       else
  22.       {
  23.          this.nLives = 3;
  24.       }
  25.       this.location = loc;
  26.       this.mcFloor = loc.mcFloor;
  27.       this.buildingsLeft = loc.buildingsLeft;
  28.       this.buildingsRight = loc.buildingsRight;
  29.       this.mcPlayer = loc.mcStuffHolder.mcPlayer;
  30.       smashing.Menu.watchProp(this,"score","text");
  31.       smashing.Menu.watchProp(this,"level","text");
  32.       smashing.Menu.watchProp(this,"highestStack","text");
  33.       smashing.Menu.watchProp(this,"maxStackScore","text");
  34.       smashing.Menu.watchProp(this,"levelScore","text");
  35.       smashing.Menu.watchProp(this,"nDistRatio","frameMeter");
  36.       smashing.Menu.watchProp(this,"lives","frameAnimMeter");
  37.       this.oPackages = new PackageHandler(loc.mcStuffHolder,loc.mcVanishing);
  38.       this.mcPlayer.aPackages = this.oPackages.oHandler.clips;
  39.       this.mcPlayer.oWorld = this;
  40.       this.mcPlayer.oPackages = this.oPackages;
  41.       this.oMusic = loc.mcMusic;
  42.    }
  43.    function onEnter()
  44.    {
  45.    }
  46.    function onExit()
  47.    {
  48.    }
  49.    function onPlay()
  50.    {
  51.       if(_global.bMute == false)
  52.       {
  53.          this.oMusic.playMusic();
  54.       }
  55.       this.mcPlayer.startWalk();
  56.       if(this.bCollapse == false)
  57.       {
  58.          this.buildingsLeft.playBuild();
  59.          this.buildingsRight.playBuild();
  60.       }
  61.    }
  62.    function onPause()
  63.    {
  64.       this.oMusic.stopMusic();
  65.       this.mcPlayer.stopWalk();
  66.    }
  67.    function onCollapse()
  68.    {
  69.       this.bCollapse = true;
  70.       this.buildingsLeft.stopBuild();
  71.       this.buildingsRight.stopBuild();
  72.       this.lives = this.lives - 1;
  73.       var _loc3_ = _global.mcRoot.mcPopups;
  74.       _loc3_._visible = true;
  75.       _loc3_.gotoAndPlay("loseTry");
  76.    }
  77.    function onUncollapse()
  78.    {
  79.       this.bCollapse = false;
  80.       if(this.lives <= 0)
  81.       {
  82.          _global.mcRoot.mcMenu.show("gameOver");
  83.       }
  84.       else
  85.       {
  86.          this.buildingsLeft.playBuild();
  87.          this.buildingsRight.playBuild();
  88.          this.mcPlayer.reset();
  89.       }
  90.    }
  91.    function onMaxStack()
  92.    {
  93.       this.maxStackScore += this.maxStackBonus;
  94.       this.flScore += this.maxStackBonus;
  95.    }
  96.    function onBonus()
  97.    {
  98.       _global.oSound.playSnd("pickUp");
  99.       this.flScore += this.bonusScore;
  100.    }
  101.    function update(nElapsed)
  102.    {
  103.       if(this.bCollapse == false)
  104.       {
  105.          this.oPackages.update(nElapsed);
  106.          this.cDist += nElapsed;
  107.          this.nDistRatio = this.cDist / this.nDist;
  108.          var _loc3_ = this.mcPlayer.nPackages - 1;
  109.          var _loc5_ = this.scoreValue * (_loc3_ * _loc3_) * nElapsed;
  110.          this.flScore += _loc5_;
  111.          this.score = Math.floor(this.flScore);
  112.          this.levelScore += _loc5_;
  113.          if(this.cDist >= this.nDist)
  114.          {
  115.             _global.mcRoot.mcMenu.show("endLevel");
  116.          }
  117.          if(this.mcPlayer.nPackages > this.highestStack)
  118.          {
  119.             this.highestStack = this.mcPlayer.nPackages;
  120.          }
  121.       }
  122.       this.mcPlayer.update(nElapsed);
  123.       if(Key.isDown(77))
  124.       {
  125.          _global.mcRoot.mcMenu.show("menu");
  126.       }
  127.       if(Key.isDown(80))
  128.       {
  129.          _global.mcRoot.oBase.pause();
  130.       }
  131.    }
  132.    function reset()
  133.    {
  134.       this.mcPlayer.reset();
  135.       this.oPackages.reset();
  136.       this.cDist = 0;
  137.       this.nDistRatio = 0;
  138.       this.levelScore = 0;
  139.       this.highestStack = 0;
  140.       this.maxStackScore = 0;
  141.       this.oMusic.reset();
  142.    }
  143.    function newGame()
  144.    {
  145.       this.mcFloor.gotoAndStop(1);
  146.       this.score = 0;
  147.       this.flScore = 0;
  148.       this.level = 1;
  149.       this.lives = this.nLives;
  150.       this.mcPlayer.reset();
  151.       this.reset();
  152.    }
  153.    function nextLevel()
  154.    {
  155.       this.level = this.level + 1;
  156.       this.mcFloor.gotoAndStop(this.level - 1 % this.mcFloor._totalframes + 1);
  157.       _global.mcRoot.mcXHair._visible = false;
  158.       this.reset();
  159.    }
  160. }
  161.